sgwt_inverse : Compute inverse sgw transform, via conjugate gradients function r=sgwt_inverse(y,L,c,arange) Inputs: y - sgwt coefficients L - laplacian c - cell array of Chebyshev coefficients defining transform arange - spectral approximation range Selectable Control Parameters tol - tolerance for conjugate gradients (default 1e-6)
0001 % sgwt_inverse : Compute inverse sgw transform, via conjugate gradients 0002 % 0003 % function r=sgwt_inverse(y,L,c,arange) 0004 % 0005 % Inputs: 0006 % y - sgwt coefficients 0007 % L - laplacian 0008 % c - cell array of Chebyshev coefficients defining transform 0009 % arange - spectral approximation range 0010 % 0011 % Selectable Control Parameters 0012 % tol - tolerance for conjugate gradients (default 1e-6) 0013 % 0014 0015 % This file is part of the SGWT toolbox (Spectral Graph Wavelet Transform toolbox) 0016 % Copyright (C) 2010, David K. Hammond. 0017 % 0018 % The SGWT toolbox is free software: you can redistribute it and/or modify 0019 % it under the terms of the GNU General Public License as published by 0020 % the Free Software Foundation, either version 3 of the License, or 0021 % (at your option) any later version. 0022 % 0023 % The SGWT toolbox is distributed in the hope that it will be useful, 0024 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0025 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0026 % GNU General Public License for more details. 0027 % 0028 % You should have received a copy of the GNU General Public License 0029 % along with the SGWT toolbox. If not, see <http://www.gnu.org/licenses/>. 0030 0031 function r=sgwt_inverse(y,L,c,arange,varargin) 0032 control_params={'tol',1e-6}; 0033 argselectAssign(control_params); 0034 argselectCheck(control_params,varargin); 0035 argselectAssign(varargin); 0036 0037 assert(iscell(c)); 0038 N=size(L,1); 0039 % first compute adj = W^*y ( sort of slowly ) 0040 fprintf('computing adjoint\n'); 0041 adj=sgwt_adjoint(y,L,c,arange); 0042 % W^* W 0043 % compute P(x) = p(x)^2 0044 fprintf('computing cheby coeff for P=p^2\n'); 0045 for j=1:numel(c) 0046 M(j)=numel(c{j}); 0047 end 0048 maxM=max(M); 0049 % dkh : code below could remove unnecessary use of cell arrays. 0050 d{1}=zeros(1,1+2*(maxM-1)); 0051 for j=1:numel(c) 0052 cpad{j}=zeros(maxM,1); 0053 cpad{j}(1:M(j))=c{j}; 0054 d{1}=d{1}+sgwt_cheby_square(cpad{j}); 0055 end 0056 wstarw = @(x) sgwt_cheby_op(x,L,d{1},arange); 0057 %% conjugate gradients 0058 fprintf('computing inverse by conjugate gradients\n'); 0059 r=cgs(wstarw,adj,tol);